package net.isanchez.gwt.client;

import net.isanchez.gwt.client.rpc.HelloWorldService;
import net.isanchez.gwt.client.rpc.HelloWorldServiceAsync;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class HelloModule implements EntryPoint {

	private VerticalPanel rootPanel;

	public void onModuleLoad() {
		RootPanel gwtPanel = RootPanel.get();
		rootPanel = new VerticalPanel();
		gwtPanel.add(rootPanel);
		HelloWorldServiceAsync service = HelloWorldService.Util.getInstance();
		AsyncCallback callback = new AsyncCallback() {
			public void onFailure(Throwable caught) {
				Window.alert("RPC error:" + caught);
			}

			public void onSuccess(Object result) {
				Window.alert((String) result);
			}
		};

		service.getHelloMessage("GWT projetct", callback);
	}

}
